Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR moves cidranger from using the IP address/prefix values from the
"net"
module in the Go standard libary to using the equivalents from the newer"net/netip"
in the standard library. This allows for some code simplification:[]byte
lengths or nil pointersnetip.Prefix
can be used directly as a map key in bruteranger as opposed to anet.IPNet
's.String()
value==
/!=
as opposed to viabytes.Equal()
The tests were updated to use
net/netip
, and run successfully.TestInsertError
andTestRemoveError
were removed, as the error they are testing for is impossible to induce withnet/netip
This is a fairly big update, and since it changes a good chunk of the API, likely warrants a version bump, though I am opening this PR to at least see if this is a change that you are interested in and if you have any changes in mind.
net/netip
was introduced in 1.18, and, as 1.19 is out now, all officially supported versions of Go (the last two releases) support this, though applications and libraries making use of cidranger would need to be rewritten or at least add wrapper code to handle this, if this version is used.